package jjy;

public class Person {
    private int age;
    public void setAge(int age) {
        if (age >= 0 && age <= 100) {
            this.age = age;
            System.out.println("年龄设置成功！");
        } else {
            System.out.println("年龄不合法，请输入0到100之间的整数");
        }
    }
    public int getAge() {
        return this.age;
    }
    public static void main(String[] args) {
        Person person = new Person();
        person.setAge(20);
        System.out.println("当前年龄：" + person.getAge());
        person.setAge(-5);
        System.out.println("当前年龄：" + person.getAge());
    }
}

